<template >
  <div class="recreation-container" style="background: #fff">
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
      <van-list
        v-model:loading="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad" style="background: #fff"
      >
        <van-cell v-for="item in list" :key="item">
          <div class="card">
            <div class="message">
              <img src="../../img/student/message.png"/>
              <div class="messageCenter">
                <div class="messageCenterDe"><span class="messageCenterTitle">公告主题主题</span><span class="messageCenterTime">2023/12/30 12:00</span></div>
                <div class="messageBottom">消息内容内容…..内容</div>
              </div>
            </div>
          </div>
        </van-cell>
      </van-list>
    </van-pull-refresh>
  </div>
</template>

<script>
export default {
  mounted() {
  },
  setup() {
    //下拉列表
    const list = ref([]);
    const loading = ref(false);
    const finished = ref(false);
    const refreshing = ref(false);
    const onLoad = () => {
      setTimeout(() => {
        if (refreshing.value) {
          list.value = [];
          refreshing.value = false;
        }
        for (let i = 0; i < 10; i++) {
          list.value.push(list.value.length + 1);
        }
        loading.value = false;
        if (list.value.length >= 40) {
          finished.value = true;
        }
      }, 1000);
    };
    const onRefresh = () => {
      finished.value = false;
      loading.value = true;
      onLoad();
    };
    return {
      refreshing,
      list,
      loading,
      finished,
      onRefresh,
      onLoad,
    };
  },
  methods: {},
}
</script>

<style scoped lang="less">
.van-cell:after{
  display: none;
}
.messageCenterDe{
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.message{
  display: flex;
  justify-content: flex-start;
  align-items: center;
  img{
    width:50px;
    height: 50px;
    margin-right: 17px;
  }
  .messageCenter{
    width: 100%;
    .messageCenterTitle{
      font-family: PingFangSC, PingFang SC;
      font-weight: bold;
      font-size: 16px;
      color: #333333;
      line-height: 22px;
      text-align: left;
      font-style: normal;
    }
    .messageCenterTime{
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 12px;
      color: #999999;
      line-height: 17px;
      text-align: left;
      font-style: normal;
    }
    .messageBottom{
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 14px;
      color: #666666;
      line-height: 20px;
      text-align: left;
      font-style: normal;
      margin-top: 6px;
    }
  }
}
</style>
